package com.rchat.pocmini.activity.qrcode;

import android.graphics.BitmapFactory;
import android.view.View;
import android.widget.ImageView;

import com.rchat.pocmini.R;
import com.rchat.pocmini.common.mvp.BaseMvpActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by ljd on 2017/8/31.
 */

public class QRCodeMvpActivity extends BaseMvpActivity<QRCodePresenterImpl, QRCodeModelImpl>
        implements QRCodeContract.View{

    @BindView(R.id.iv_qr_code)
    ImageView ivQRCode;

    @BindView(R.id.iv_back)
    ImageView ivBack;

    private int qrStringCode;

    @Override
    public void initPresenter() {
        mPresenter.setVM(this, mModel);
    }

    @Override
    public int getLayoutId() {
        return R.layout.qr_code_activity_layout;
    }

    @Override
    public void initView() {
        qrStringCode = getIntent().getIntExtra("code", 0);

    }

    @Override
    public void doAfterInitView() {
        mPresenter.createQRCode(qrStringCode);
    }

    @OnClick({R.id.iv_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;

        }
    }

    @Override
    public void showQrCode(String filePath) {
        ivQRCode.setImageBitmap(BitmapFactory.decodeFile(filePath));
    }
}
